<template>
    <div id="system">
        <div class="system-title">系统参数编辑</div>
        <el-table
            :header-cell-style="{color:'#555555'}"
            class="black"
            :data="tableData"
            stripe
            border
            style="width: 100%">
            <el-table-column
                prop="id"
                label="ID"
                align="center">
            </el-table-column>
            <el-table-column
                prop="key"
                label="参数编码"
                align="center">
            </el-table-column>
            <el-table-column
                prop="remark"
                label="参数描述"
                align="center">
            </el-table-column>
            <el-table-column
                prop="value"
                label="参数值"
                align="center">
                <template slot-scope="{row}">
                    <input class="edit-cell" v-model="row.value">
                </template>
            </el-table-column>
            <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                    <el-button @click="editData(scope.row)" size="small">保存</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
export default {
    name: 'user-man-detail',
    data () {
        return {
            tableData: []
        }
    },
    created () {
    },
    mounted () {
        // 获取详情数据
        this.getData()
    },
    methods: {
        handleRemove (file, fileList) {
            console.log(file, fileList)
        },
        handlePictureCardPreview (file) {
            this.imageUrl = file.url
            this.dialogVisible = true
            // console.log(this.dialogImageUrl)
        },
        // 系统参数列表
        getData () {
            var _this = this
            this.$api.system.getData(res => {
                // 隐藏加载动画
                // this.$vux.loading.hide()
                if (res.code === 200) {
                    var data = res.page.list
                    _this.tableData = data
                }
            })
        },
        // 更新系统参数
        editData (params) {
            let _this = this
            let data = {
                'params': params
            }
            this.$api.system.editData(data, res => {
                // 隐藏加载动画
                // this.$vux.loading.hide()
                if (res.code === 200) {
                    _this.$message('修改成功')
                } else {
                    _this.$message('修改失败')
                }
            })
        }
    }
}
</script>

<style lang="less" scoped>
    #system {
        position: relative;
        width: 100%;
        height: 100%;
        .margin-bottom-12 {
            margin-bottom: 10px;
        }
        .el-row {
            margin-bottom: 20px;
            &:last-child {
                margin-bottom: 0;
            }
        }
        .el-col {
            border-radius: 4px;
        }
        .grid-content {
            position: relative;
            height: 40px;
        }
        .grid-padding {
            /* padding-left: 20px; */
            padding-right: 20px;
        }
        .grid-title {
            float: left;
            width: 72px;
            height: 40px;
            line-height: 40px;
            font-size: 14px;
            color: #333;
            text-align: center;
        }
        .grid-input {
            float: left;
            width: 130px;
            height: 40px;
            line-height: 40px;
            font-size: 14px;
            color: #333;
            text-align: center;
        }
        .row-bg {
            padding: 10px 0;
            background-color: #f9fafc;
        }
        .footer-page {
            width: 540px;
            margin: 0 auto;
            padding-top: 20px;
        }
    }
</style>
